package adaptive.opencom;

import OpenCOM.IConnections;
import OpenCOM.ILifeCycle;
import OpenCOM.IMetaInterface;
import OpenCOM.IUnknown;
import OpenCOM.OCM_SingleReceptacle;
import OpenCOM.OpenCOMComponent;
import adaptive.ime.MyKeyboardService.KeyboardSize;

public class AbstractKeyboardPolicyComponent extends OpenCOMComponent
	implements IAdaptationPolicy, IUnknown, ILifeCycle, IMetaInterface, IConnections {
	
	public OCM_SingleReceptacle<IEventMonitor> rcEventMonitor;
	protected KeyboardSize mSize;
	
	public AbstractKeyboardPolicyComponent(IUnknown mpIOCM) {
		super(mpIOCM);
		
		rcEventMonitor = new OCM_SingleReceptacle<IEventMonitor>(IEventMonitor.class);
		
		mSize = KeyboardSize.SMALL;
	}

	// ILifeCycle operations
	@Override
	public boolean startup(Object data) {
		return true;
	}

	@Override
	public boolean shutdown() {
		return true;
	}
	

	// IAdaptationPolicy Operations
	@Override
	public AdaptationRequest adaptationRequest() {
		return new AdaptationRequest();
	}

	// IConnections
	@Override
	public boolean connect(IUnknown pSinkIntf, String riid, long provConnID) {
		if(riid.equalsIgnoreCase("adaptive.opencom.IEventMonitor")) {
			return this.rcEventMonitor.connectToRecp(pSinkIntf, riid, provConnID);
		}
		
		return false;
	}

	@Override
	public boolean disconnect(String riid, long connID) {
		if(riid.equalsIgnoreCase("adaptive.opencom.IEventMonitor"))
			return this.rcEventMonitor.disconnectFromRecp(connID);
		
		return false;
	}
}
